package com.banshuibao.bsb_android.activity;

import android.graphics.Bitmap;
import android.graphics.PointF;
import android.os.Bundle;
import android.view.View;

import com.banshuibao.bsb_android.Constants;
import com.banshuibao.bsb_android.R;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.SimpleTarget;
import com.davemorrissey.labs.subscaleview.ImageSource;
import com.davemorrissey.labs.subscaleview.ImageViewState;
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;

/**
 * Created by zyh on 2018/5/30.
 */

public class TaxSearchDetailActivity extends BaseActivity {

    private String url, title;

    private SubsamplingScaleImageView img;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activitiy_tax_search_detail);

        initData();
        initView();
    }

    private void initData() {
        url = getIntent().getStringExtra("url");
        title = getIntent().getStringExtra("title");
    }

    private void initView() {
        setTitleText(title);
        img = findViewById(R.id.img);
        img.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CUSTOM);
        img.setMinScale(1.0F);
        img.setLayerType(View.LAYER_TYPE_SOFTWARE, null);//解决国片过大过长展示不了

        showProgressDialog();
        Glide.with(context).load(Constants.Url.SHOW_IMAGE + url).asBitmap().into(new SimpleTarget<Bitmap>() {
            @Override
            public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                img.setImage(ImageSource.bitmap(resource), new ImageViewState(0.5F, new PointF(0, 0), 0));
                cancelProgressDialog();
            }
        });
    }
}
